package com.blb.day12_spring_boot.controller;


import com.blb.day12_spring_boot.entity.Book;
import com.blb.day12_spring_boot.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("book")
public class BookController {

    @Autowired
    private BookService bookService;

    @RequestMapping("list")
    public String list(Model model){
        List<Book> list = bookService.list();
        model.addAttribute("books",list);
        return "index";
    }
}
